//网络请求
const urlApi ="http://localhost:3000"
async function login(){
  wx.login({
    success(res1) {
      wx.request({
        method: "get",
        url: `${urlApi}/api/login`,
        data: {
          js_code: res1.code
        },
        success(res) {
          console.log(res)
        }
      })
    }
  })
}

//获取动态信息
function getDynamic(){
  var data = new Promise((resolve, reject) => {
    wx.request({
      url: `${urlApi}/dynamic/list`,
      success: (res) => {
        resolve(res)
      }
    })
  })
   return data
}

//获取校园资讯
function shcollData() {
  var data = new Promise((resolve, reject) => {
    wx.request({
      url: `${urlApi}/notice/list`,
      success: (res) => {
        resolve(res)
      }
    })
  })
  return data
}

//获取成绩
function gradesData() {
  var data = new Promise((resolve, reject) => {
    wx.request({
      url: `${urlApi}/dynamic/grades`,
      success: (res) => {
        resolve(res)
      }
    })
  })
  return data
}

//获取课程表
function timetableData() {
  var data = new Promise((resolve, reject) => {
    wx.request({
      url: `${urlApi}/dynamic/course`,
      success: (res) => {
        resolve(res)
      }
    })
  })
  return data
}
module.exports.login=login
module.exports.getDynamic=getDynamic
module.exports.shcollData = shcollData
module.exports.gradesData = gradesData
module.exports.timetableData = timetableData  